package com.itheima.mapper;

import com.itheima.domain.Order;
import com.itheima.domain.User;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrderMapper {
    @Select("select * from `order`")
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "orderTime",column = "ordertime"),
            @Result(property = "total",column = "total"),
            @Result(property = "user",column = "uid", javaType = User.class, one = @One(select = "com.itheima.mapper.UserMapper.findById"))
    })
    List<Order> findAll();

    @Select("select * from `order` where uid=#{id}")
    Order findByUid(int id);
}
